// pages/rank/rank.js
var app = getApp()
var base = require('../../conf.js')
Page({
  changeColorAndState: function () {
    var bgColor = this.data.BackgroundColor == 'white' ? '#700DDA' : 'white';
    var fontColor = this.data.FontColor == '#700DDA' ? 'white' : '#700DDA';
    // 设置背景颜色数据
    this.setData({
      BackgroundColor: bgColor,
      FontColor: fontColor,
    });
    var that = this;
    that.setData({
      isShow1: (!that.data.isShow1),
      isShow2: (!that.data.isShow2)
    })
  },
  changeColorAndState1: function () {
    var bgColor = this.data.BackgroundColor1 == 'white' ? '#700DDA' : 'white';
    var fontColor = this.data.FontColor1 == '#700DDA' ? 'white' : '#700DDA';
    // 设置背景颜色数据
    this.setData({
      BackgroundColor1: bgColor,
      FontColor1: fontColor,
    });
    var that = this;
    that.setData({
      isShow3: (!that.data.isShow3),
      isShow4: (!that.data.isShow4)
    })
  },
  changeColorAndState2: function () {
    var bgColor = this.data.BackgroundColor2 == 'white' ? '#700DDA' : 'white';
    var fontColor = this.data.FontColor2 == '#700DDA' ? 'white' : '#700DDA';
    // 设置背景颜色数据
    this.setData({
      BackgroundColor2: bgColor,
      FontColor2: fontColor,
    });
    var that = this;
    that.setData({
      isShow5: (!that.data.isShow5),
      isShow6: (!that.data.isShow6)
    })
  },
  data:{
    week: {
      info: '年度活动'
    },
    month: {
      name: '每月活动'
    },
    year: {
      name: '每周活动'
    },
    day: {
      name: '每日活动'
    },
    title: {
      year: '年榜',
      month: '月榜',
      share: '分享榜'
    },
    isShow1: true,
    isShow2: false,
    isShow3: true,
    isShow4: false,
    isShow5: true,
    isShow6: false,
    consumes:[],
    levelImg:[{
      icon: 'http://pbr2drfuy.bkt.clouddn.com/1.png',
    },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/2.png',
      },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/3.png',
      },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/4.png',
      },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/5.png',
      }
      , {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/6.png',
      }
      ,
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/7.png',
      },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/8.png',
      },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/9.png',
      },
      {
        icon: 'http://pbr2drfuy.bkt.clouddn.com/10.png',
      }],
    consumes1: [],
    consumes2: [],
    BackgroundColor:'white',
    FontColor:'#700DDA',
    BackgroundColor1: 'white',
    FontColor1: '#700DDA',
    BackgroundColor2: 'white',
    FontColor2: '#700DDA'
  },
  onLoad(){
    this.getYearConsume()
    this.getMonthConsume()
    this.getWeekConsume()
  },
  getYearConsume: function () {
    var self = this;
    wx.request({
      url: base.url + '/year',
      method: 'get',
      header: {
        "Content-Type": "application/json;charset=UTF-8",
        'userToken': base.token_Date
      },
      success: function (res) {
        var yearList = res.data.data
        self.setData({
          consumes: yearList
        })
      }
    })
  },
  getMonthConsume: function () {
    var self = this;
    wx.request({
      url: base.url + '/month',
      method: 'get',
      header: {
        "Content-Type": "application/json;charset=UTF-8",
        'userToken': base.token_Date
      },
      success: function (res) {
        console.log(res.data.data)
        var monthList = res.data.data
        self.setData({
          consumes1: monthList
        })
      }
    })
  },
  getWeekConsume: function () {
    var self = this;
    wx.request({
      url: base.url + '/week',
      method: 'get',
      header: {
        "Content-Type": "application/json;charset=UTF-8",
        'userToken': base.token_Date
      },
      success: function (res) {
        console.log(res.data.data)
        var weekList = res.data.data
        self.setData({
          consumes2: weekList
        })
      }
    })
  },
  toOrder: function () {
    wx.navigateTo({
      url: "/pages/home-page/order"
    })
  },
  toGame: function () {
    wx.navigateTo({
      url: "/pages/active/action-detail"
    })
  },
  turn_activity: function () {
    wx.navigateTo({
      url: "/pages/pic/activity"
    })
  }
})